package huiwengliantable;

import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class Main {//链表回文
    public static class ListNode {
   int val;
    ListNode next = null;

        public ListNode(int val) {
            this.val = val;
        }
    }
    public boolean isPalindrome (ListNode head){
        ListNode cur=head;
      if(cur==null){
          return true;
      }
      StringBuilder stringBuilder1=new StringBuilder();
      stringBuilder1.append()

        return false;
    }
  public boolean isPalindrome1 (ListNode head) {
        ListNode cur=head;
        if(cur==null) {
            return true;
        }
      Stack<ListNode> stack=new Stack<>();
        while (cur!=null){
            stack.push(cur);
            cur=cur.next;
        }
        while (!stack.isEmpty()){
           ListNode curn=stack.peek();
           if(curn.val==cur.val){
               cur=cur.next;
               stack.pop();
           }else {
               return  false;
           }
        }
        return true;
    }
}
